<template>
    <view class="container" v-if="data" :style="themeColor">
        <view class="title">
            <text>{{ data.Title }}</text>
        </view>
        <view class="time">
            <text>{{ data.AddTime }}</text>
        </view>
        <rich-text v-if="data" :nodes="formatRichTextFn(data.Content)"> </rich-text>
    </view>
</template>

<script>
import { formatRichText } from "@/uni-sub-base/utils/elementUtil.js"
import { UpdateCheckSiteMessageTime, GetInfo, AddVisitMsg } from "@/service/api/siteMessage.js"

export default {
    components: {},
    data() {
        return {
            data: null,
            id: 0,
        }
    },
    onLoad(e) {
        if (e) {
            this.id = e.id
        }
    },
    mounted() {
        this.updateCheckSiteMessageTime()
        this.addVisitMsg()
        this.getInfo()
    },
    methods: {
        //获取详情
        getInfo() {
            let param = {
                id: this.id,
            }
            let path = `?id=${this.id}`
            GetInfo(param, path).then((res) => {
                if (res.State == 1 && res.Data) {
                    this.data = res.Data
                }
            })
        },
        //设置浏览
        updateCheckSiteMessageTime() {
            let path = `?id=${this.id}`
            UpdateCheckSiteMessageTime({}, path).then((res) => {})
        },
        //设置浏览
        addVisitMsg() {
            let path = `?id=${this.id}`
            AddVisitMsg({}, path).then((res) => {})
        },
        formatRichTextFn(text) {
            return formatRichText(text)
        },
    },
}
</script>

<style lang="scss">
.container {
    padding: $app-page-padding;
}
.title {
    text {
        font-size: $font-size-36;
        font-weight: 700;
    }
}
.time {
    margin-bottom: 20rpx;
    text {
        color: $app-color-text-tip;
    }
}
</style>
